import java.util.Scanner;

public class 更小的数 {
    private static int N = 5001;

    public static void main(String[] args) {
        //定义dp数组
        int dp[][] = new int[N][N];
        //输入一个数
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        str = " " + str;
        int strLen = str.length();
        int res = 0;
        //外层循环为子串长度
        //内层循环是具体的子串起始点
        for (int len = 1; len <= strLen; len++) {
            for (int l = 1; l + len - 1 <= strLen - 1; l++) {
                int r = l + len - 1;
                int lnum = Integer.parseInt(String.valueOf(str.charAt(l)));
                int rnum = Integer.parseInt(String.valueOf(str.charAt(r)));
                if (lnum < rnum) {
                    //反转后更大
                    dp[l][r] = -1;
                } else if (lnum > rnum) {
                    //反转后更小
                    dp[l][r] = 1;
                } else {
                    //往中间比较
                    dp[l][r] = dp[l + 1][r - 1];
                }
                if (dp[l][r] == 1) {
                    res++;
                }
            }
        }
        System.out.println(res);
    }
}
